<?php

namespace api\controller;

use common\controller\VerifyController;
use common\exception\LogicException;
use common\service\TaskV2Service;
use think\Request;
use think\Response;

class WorkbenchController extends VerifyController
{
    private TaskV2Service $taskV2Service;

    public function __construct()
    {
        parent::__construct();
        $this->taskV2Service = TaskV2Service::getInstance();
    }

    /**
     * 与我相关任务统计
     * @param Request $request
     */
    public function getTaskMemberCount(Request $request)
    {
        $param = $request->post();
        $param = $param['param'];
//        $responseFormatType = $param['response_format_type'];
        $code = $param['code'] ?? '';
        $filter = $param['filter'] ?? [];
        $page = $param['page'] ?? [0, 50];
        $limit = $param['limit'] ?? 100;
        $fields = $param['fields'] ?? '';
        $rangeTime = $param['range_time'] ?? [0, 0];
        $res = $this->taskV2Service->getTaskMember($fields, 'count', $code, $rangeTime, $filter, $page, "", $limit);
        return json(success_response('', $res));
    }

    /**
     * 与我相关任务列表
     * @param Request $request
     */
    public function getTaskMemberList(Request $request)
    {
        $param = $request->post();
        $param = $param['param'];
//        $responseFormatType = $param['response_format_type'];
        $code = $param['code'] ?? '';
        $filter = $param['filter'] ?? [];
        $page = $param['page'] ?? [0, 50];
        $order = $param['order'] ?? "";
        $limit = $param['limit'] ?? 100;
        $fields = $param['fields'] ?? '';
        $rangeTime = $param['range_time'] ?? [0, 0];
        $res = $this->taskV2Service->getTaskMember($fields, 'list', $code, $rangeTime, $filter, $page, $order, $limit);
        return json(success_response('', $res));
    }

}
